<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Excel;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use App\Helpers\ExcelHelper;

class ExcelController extends Controller
{
    //

    public function index(){
//        echo 'excel-index';die;
        $data=DB::table('app_apply')->get()->toArray();
        $excelObj=new ExcelHelper;
//        输出为excel
        $tablename=Config::get('excel.fileName._default');
//        echo $tablename;die;
        $re=$excelObj->exportFast($data,$tablename);
        echo '<pre>';
        print_r($re);die;
        if($re){
            echo '输出成功';die;
        }
//        ========输入excel
         $fullPath = \Config::get("excel.importPath").'slave'.'.xls';
        $re=$excelObj->importFast($fullPath);

    }


//    导入数据
    public function enterExcel(){
//        echo 'enterExcel';die;
        $excelObj=new ExcelHelper;
        $arr=$excelObj->importFast();
        echo '<pre/>';
        print_r($arr);die;
    }

}
